package com.ruoyi.web.controller.fee;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.FeeGuahao;
import com.ruoyi.system.service.IFeeGuahaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 挂号交费信息Controller
 * 
 * @author ruoyi
 * @date 2024-06-27
 */
@RestController
@RequestMapping("/fee/guahao")
public class FeeGuahaoController extends BaseController
{
    @Autowired
    private IFeeGuahaoService feeGuahaoService;

    /**
     * 查询挂号交费信息列表
     */
    @PreAuthorize("@ss.hasPermi('fee:guahao:list')")
    @GetMapping("/list")
    public TableDataInfo list(FeeGuahao feeGuahao)
    {
        startPage();
        List<FeeGuahao> list = feeGuahaoService.selectFeeGuahaoList(feeGuahao);
        return getDataTable(list);
    }

    /**
     * 导出挂号交费信息列表
     */
    @PreAuthorize("@ss.hasPermi('fee:guahao:export')")
    @Log(title = "挂号交费信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FeeGuahao feeGuahao)
    {
        List<FeeGuahao> list = feeGuahaoService.selectFeeGuahaoList(feeGuahao);
        ExcelUtil<FeeGuahao> util = new ExcelUtil<FeeGuahao>(FeeGuahao.class);
        util.exportExcel(response, list, "挂号交费信息数据");
    }

    /**
     * 获取挂号交费信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('fee:guahao:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(feeGuahaoService.selectFeeGuahaoById(id));
    }

    /**
     * 新增挂号交费信息
     */
    @PreAuthorize("@ss.hasPermi('fee:guahao:add')")
    @Log(title = "挂号交费信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FeeGuahao feeGuahao)
    {
        return toAjax(feeGuahaoService.insertFeeGuahao(feeGuahao));
    }

    /**
     * 修改挂号交费信息
     */
    @PreAuthorize("@ss.hasPermi('fee:guahao:edit')")
    @Log(title = "挂号交费信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FeeGuahao feeGuahao)
    {
        return toAjax(feeGuahaoService.updateFeeGuahao(feeGuahao));
    }

    /**
     * 删除挂号交费信息
     */
    @PreAuthorize("@ss.hasPermi('fee:guahao:remove')")
    @Log(title = "挂号交费信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(feeGuahaoService.deleteFeeGuahaoByIds(ids));
    }
}
